<?php

class CheckMode_3d
{

    public $acl;
    public $chkVal;
    public $systemcheck;
    public $gametype;
    public $show3D3S;

    public function CheckMode_3d($acl , $chkVal = 3 , $gametype = 1)
    {
        global $g_gametype_3d;
        $conf = new Config();
        if ( isset($g_gametype_3d[$gametype]) )
        {
            $this->systemcheck = $conf->Get("systemcheck_".$g_gametype_3d[$gametype]['en']);
            $this->show3D3S = $g_gametype_3d[$gametype]['type'] - 1;
        }
        else
        {
            exit("error game type");
        }
        $this->gametype = $gametype;
        $this->acl = $acl;
        $this->chkVal = $chkVal;
    }

    public function getMyBetname()
    {
        global $g_betname_3d;
        global $g_betname_3s;
        if ( $this->show3D3S == 1 )
        {
            return $g_betname_3s;
        }
        return $g_betname_3d;
    }

    public function getMyAutorate()
    {
        global $g_autorate_3d;
        global $g_autorate_3s;
        if ( $this->show3D3S == 1 )
        {
            return $g_autorate_3s;
        }
        return $g_autorate_3d;
    }

    public function enableMode()
    {
        global $g_init_mode_3d;
        if ( $g_init_mode_3d )
        {
            return false;
        }
        return true;
    }

    public function system3dCheck()
    {
        if ( $this->acl == 255 )
        {
            return false;
        }
        if ( $this->systemcheck == 1 )
        {
            return true;
        }
        return false;
    }

    public function chkValDisabled()
    {
        switch ( $this->chkVal )
        {
            case 1 :
                return false;
            case 3 :
                if ( in_array($this->show3D3S , array ( 0 , 1,3)) )
                {
                    return false;
                }
                return true;
            case 5 :
                if ( in_array($this->show3D3S , array ( 2,3 )) )
                {
                    return false;
                }
                return true;
        }
        return true;
    }

    public function checkShow3dPage()
    {
        global $g_conf;
        global $g_gametype_3d;
        $ui = new UI_3D(true);
        if ( $this->enableMode() )
        {
            $ui->showErrorPage("登入模式不含33，若有任何疑问，请洽管理者。");
            exit();
        }
        else
        {
            if ( $this->chkValDisabled() )
            {
                $ui->showErrorPage("无法显示" , true);
                exit();
            }
            else
            {
                if ( $this->system3dCheck() )
                {
                    $ui->showErrorPage($g_gametype_3d[$this->gametype]['ch']."系统维护中" , true);
                    exit();
                }
            }
        }
    }

}

?>